package com.dkd.testClass.controller;


import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.core.domain.R;
import com.dkd.common.core.page.TableDataInfo;
import com.dkd.testClass.domain.TestClass;
import com.dkd.testClass.service.ITestClassService;
import com.dkd.testRank.domain.TestRank;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 班级表
 * </p>
 * @author zwy
 * @since 2025-06-10
 */
@Api(tags = "班级表")
@RestController
@RequestMapping("/test/class")
public class TestClassController extends BaseController {

    @Autowired
    ITestClassService classService;
    /**
     * 查询用户列表
     */
    @ApiOperation("查询列表")
    @PreAuthorize("@ss.hasPermi('testClass:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestClass testClass) {
        startPage();
        return getDataTable(classService.selectList(testClass));
    }

    /**
     * 详情
     *
     * @param id
     * @return 班级以及学生列表
     */
    @ApiOperation("查询详情")
    @PreAuthorize("@ss.hasPermi('testClass:class:query')")
    @GetMapping(value = "/{id}")
    public R<TestClass> getInfo(@PathVariable("id") Integer id) {
        return R.ok(classService.selectById(id));
    }

    /**
     * 新增相关信息
     */
    @ApiOperation("新增及其相关信息")
    @PreAuthorize("@ss.hasPermi('testClass:class:add')")
    @PostMapping
    public AjaxResult insertTestRank(@RequestBody TestClass testClass) {
        return AjaxResult.success(classService.insertTestClass(testClass));
    }

    /**
     * 批量删除以及相关信息
     *
     * @param ids 需要删除的rank ID数组
     * @return 删除操作的结果
     */
    @ApiOperation("批量删除及其相关信息")
    @PreAuthorize("@ss.hasPermi('testClass:class:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult deleteTestRank(@PathVariable Integer[] ids) {
        return AjaxResult.success(classService.deleteTestClass(ids));
    }


    /**
     * 修改
     * @return 返回AjaxResult对象，用于封装操作结果
     */
    @ApiOperation("修改及其相关信息")
    @PreAuthorize("@ss.hasPermi('testClass:class:edit')")
    @PutMapping
    public AjaxResult updateTestRank(@RequestBody TestClass testClass) {
        return AjaxResult.success(classService.updateTestClass(testClass));
    }
}
